<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="/includes.jsp"%>

<h1 class="layout">Search Report</h1>

<table>
    <tr><th class="layout">Root Node:</th><td class="layout"><beans:write name="searchReportDTO" property="rootPath"/></td></tr>
    <tr><th class="layout">Report Date:</th><td class="layout"><beans:write name="searchReportDTO" property="reportDate" format="yyyy-MM-dd"/></td></tr>
    <tr><th class="layout">Task Count:</th><td class="layout"><beans:write name="searchReportDTO" property="taskCount"/></td></tr>
</table>

<table class="styled" cellspacing="0">
    <tr>
        <th class="styled">ID</th>
        <th class="styled">Date/Name/Person</th>
        <th class="styled">Details</th>
    </tr>
    <logic:iterate name="searchReportDTO" property="searchEntries" id="entry" indexId="rowIndex">
        <% // use the iteration index to alternate row colours
          String bgClass=(rowIndex.intValue() % 2 == 0) ? "shaded0" : "shaded1"; %>
        <logic:iterate name="entry" property="transactions" id="transaction">
            <tr class="<%=bgClass%>">
                <logic:equal name="transaction" property="type" value="Create">
                    <% int val = 15 - ((SearchEntry)entry).getPriority().intValue() * 15 / 100; %>
                    <td class="styled" style="background-color:#f<%=Integer.toHexString(val) %><%=Integer.toHexString(val) %>" rowspan="<beans:write name="entry" property="numTransactions"/>"><beans:write name="entry" property="taskId"/></td>
                </logic:equal>
                <td class="styled" style="white-space: nowrap;">
                    <b><beans:write name="transaction" property="type"/></b><br/>
                    <beans:write name="transaction" property="date" format="yyyy-MM-dd"/><br/>
                    <beans:write name="transaction" property="person"/>:<beans:write name="transaction" property="user"/>
                </td>
                <td class="styled" width="100%">
                    <table class="styled-no-outline" cellspacing="0" cellpadding="0">
                        <logic:iterate name="transaction" property="rows" id="row">
                            <tr><td style="text-indent: -30; padding-left: 30;">
                                <b><beans:write name="row" property="name"/>:</b>
                                <logic:equal name="row" property="value" value="">
                                    <i>blank</i><br/>
                                </logic:equal>
                                <logic:notEqual name="row" property="value" value="">
                                    <velocityme:markup><beans:write name="row" property="value"/></velocityme:markup><br/>
                                </logic:notEqual> 
                            </td></tr>
                        </logic:iterate>
                        <logic:present name="transaction" property="fileAttachmentValue">
                            <tr><td style="text-indent: -30; padding-left: 30;">
                                <b>Attachment:</b>
                                <beans:write name="transaction" property="fileAttachmentValue.name"/>
                            </td></tr>
                        </logic:present>
                    </table>
                </td>
            </tr>
        </logic:iterate>
    </logic:iterate>
</table>

<div class="buttons">
    <em><small>Report created by Velocityme on <beans:write name="searchReportDTO" property="reportDate" format="yyyy-MM-dd HH:mm:ss"/></small></em>
</div>
